/* 
* Copyright (C) 2011-2018 ShenZhen iBOXSaaS Information Technology Co.,Ltd. 
* 
* All right reserved. 
* 
* This software is the confidential and proprietary 
* information of iBOXSaaS Company of China. 
* ("Confidential Information"). You shall not disclose 
* such Confidential Information and shall use it only 
* in accordance with the terms of the contract agreement 
* you entered into with iBOXSaaS inc. 
* 
*/

package com.iboxpay.open.gateway.config;

import org.iboxpay.open.common.utils.SnowflakeIdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.iboxpay.open.gateway.basedata.BaseData;
import com.iboxpay.open.gateway.routes.OpenGatewayRouteLocator;


/**
 * 
 * OpenGatewayBeanConfig.java
 * @author xuxiao
 * @date 2018/06/21
 */
@Configuration
public class OpenGatewayBeanConfig {

    @Bean
    public SnowflakeIdWorker snowflakeIdWorker() {
        return new SnowflakeIdWorker(0,0);
    }
    
    @Autowired
    private ZuulProperties zuulProperties;
    
    @Autowired
    private ServerProperties serverProperties;
    
    @Autowired
    private BaseData baseData;
    
    @Bean
    public OpenGatewayRouteLocator routeLocator() {
        OpenGatewayRouteLocator result = new OpenGatewayRouteLocator(serverProperties.getServletPrefix(), zuulProperties);
        result.setBaseData(baseData);
        return result;
    }
}
